import subprocess
from functools import partial

import execjs
import requests


subprocess.Popen = partial(subprocess.Popen, encoding='utf-8')
url = 'https://music.163.com/weapi/song/enhance/player/url/v1?csrf_token=9be1d02844149803bcfb1c7875e69010'
with open('zhang.js', 'r', encoding='utf-8') as f:
    js_code = f.read()
a = execjs.compile(js_code)

b = a.call('get_token')
print(b)

res = requests.post(url, data={
    'params': b['encText'],
    'encSecKey': b['encSecKey']
}, headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"} )
print(res.text)